<form action="/user/records" method="get" class="filter">

	<label for="username">帐号</label>
	<input type="text" class="text" name="username" autocomplete="off"/>

	<label for="permission_group">权限分组</label>
	<select name="permission_group">
		<option value="0">全部</option>
		<?php foreach($permission_groups as $permission_group): ?>
		<option value="<?php echo $permission_group->id;?>">
			<?php echo $permission_group->name;?>
		</option>
	<?php endforeach;?>
	</select>

	<label for="sex">性别</label>
	<select name="sex">
		<option value="0">全部</option>
		<option value="1">男</option>
		<option value="2">女</option>
	</select>

	<label for="is_freezed">状态</label>
	<select name="is_freezed">
		<option value="0">全部</option>
		<option value="1">已冻结</option>
		<option value="2">已激活</option>
	</select>
	<label for="created_at">创建时间</label>
	<input type="text" class="text datetime" name="start" autocomplete="off"/> 到 <input type="text" class="text datetime" name="end" autocomplete="off"/>
	<input type="submit" class="submit" value="检索"/>
</form>

<ul class="button">
    <li><a href="javascript:void(0);" class="add">添加帐号</a></li>
	<!--<li><a href="javascript:void(0);" class="freeze-batch">批量冻结</a></li>-->
</ul>

<table class="records">
    <thead>
		<tr>
			<th><input type="checkbox" name="select-all" class="select-all" value="0"/></th>
			<th><a href="javascript:void(0);">用户名</a></th>
			<th><a href="javascript:void(0);">所属权限分组</a></th>
			<th><a href="javascript:void(0);">性别</a></th>
			<th><a href="javascript:void(0);">邮箱</a></th>
			<th><a href="javascript:void(0);">状态</a></th>
			<th><a href="javascript:void(0);">创建时间</a></th>
			<th>操作</th>
		</tr>
    </thead>
    <tfoot><tr><td colspan="8"></td><tr></tfoot>
    <tbody><tr><td colspan="8" style="text-align: center;">Loading...</td><tr></tbody>
</table>

<script type="text/x-jquery-tmpl" id="form-template">
    <form action="/backend/user/${action}" method="post">
		<input type="hidden" name="id" value="${id}"/>
		<div class="form-row">
			<label for="username">帐号</label>
			<input type="text" class="text" name="username" value="${username}"/>
		</div>
		{{if action=='insert'}}
		<div class="form-row">
			<label for="password">密码</label>
			<input type="password" class="text" name="password" value="${password}"/>
		</div>
		<div class="form-row">
			<label for="repeat_password">重复密码</label>
			<input type="password" class="text" name="repeat_password" value="${repeat_password}"/>
		</div>
		{{/if}}
		<div class="form-row">
			<label for="permission_group">权限分组</label>
			<select name="permission_group">
				<option value="0">选择</option>
			<?php foreach($permission_groups as $permission_group): ?>
				<option value="<?php echo $permission_group->id;?>">
					<?php echo $permission_group->name;?>
				</option>
			<?php endforeach;?>
			</select>
		</div>
		<div class="form-row">
			<label for="sex">性别</label>
			{{if sex}}
			<input type="radio" name="sex" value="1" {{if sex==1}}checked="checked"{{/if}}/>男
				   <input type="radio" name="sex" value="2" {{if sex==2}}checked="checked"{{/if}}/>女
				   {{else}}
				   <input type="radio" name="sex" value="1" checked="checked"/>男
			<input type="radio" name="sex" value="2" />女
			{{/if}}
		</div>
		<div class="form-row">
			<label for="email">邮箱</label>
			<input type="text" class="text email" name="email" value="${email}"/>
		</div>
		<div class="form-button">
			<input type="submit" value="提交" name="submit"/>
		</div>
    </form>
</script>

<script type="text/x-jquery-tmpl" id="list-template">
    <tr>
		<td><input type="checkbox" name="id[]" value="${id}"/></td>
		<td>${username}</td>
		<td>${permission_group_name}</td>
		<td>{{if sex==1}}男{{else}}女{{/if}}</td>
		<td>${email}</td>
		<td class="action">
			{{if is_freezed==1}}
				<a href="javascript:void(0);" class="unfreeze" title="已冻结，点击解冻">
					<img src="/assets/img/freeze.png" alt="解冻"/>
				</a>
			{{else}}
				<a href="javascript:void(0);" class="freeze" title="已激活，点击冻结">
					<img src="/assets/img/unfreeze.png" alt="冻结"/>
				</a>
			{{/if}}
		</td>
		<td>${created_at}</td>
		<td class="action">
			<a href="javascript:void(0);" class="edit" title="编辑">
				<img src="/assets/img/edit.png" alt="编辑"/>
			</a>
		</td>
    </tr>
</script>

<script type="text/x-jquery-tmpl" id="none-template">
    <tr><td colspan="7" style="text-align: center;">没有搜索到结果。</td></tr>
</script>